package com.liaoban.app.helper;

import android.support.v4.content.ContextCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.view.View;
import android.view.ViewGroup;

import com.liaoban.app.R;

/**
 * BaseActivity与BaseFragment中共用的函数
 * Created by ybc on 2017/6/15.
 */

public class BaseHelper {

    public static void initSwipeRefreshLayoutColor(View view) {
        int colorPrimary = ContextCompat.getColor(view.getContext(), R.color.btn_yellow);
        if (view instanceof SwipeRefreshLayout) {
            ((SwipeRefreshLayout) view).setColorSchemeColors(colorPrimary);
        } else if (view instanceof ViewGroup) {
            ViewGroup group = (ViewGroup) view;
            for (int i = 0; i < group.getChildCount(); i++) {
                initSwipeRefreshLayoutColor(group.getChildAt(i));
            }
        }
    }
}
